package com.shqcjd.yunweiyanoperator.greendao;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.shqcjd.yunweiyanoperator.model.pojo.OfflineProblemBean.InterConverter;
import com.shqcjd.yunweiyanoperator.model.pojo.OfflineProblemBean.StringConverter;
import java.util.List;

import com.shqcjd.yunweiyanoperator.model.pojo.OfflineProblemBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "OFFLINE_PROBLEM_BEAN".
*/
public class OfflineProblemBeanDao extends AbstractDao<OfflineProblemBean, Long> {

    public static final String TABLENAME = "OFFLINE_PROBLEM_BEAN";

    /**
     * Properties of entity OfflineProblemBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property ProjectName = new Property(1, String.class, "projectName", false, "PROJECT_NAME");
        public final static Property Kks = new Property(2, String.class, "kks", false, "KKS");
        public final static Property TaskCode = new Property(3, String.class, "taskCode", false, "TASK_CODE");
        public final static Property TaskId = new Property(4, String.class, "taskId", false, "TASK_ID");
        public final static Property ProblemInfo = new Property(5, String.class, "problemInfo", false, "PROBLEM_INFO");
        public final static Property Types = new Property(6, String.class, "types", false, "TYPES");
        public final static Property Imgs = new Property(7, String.class, "imgs", false, "IMGS");
        public final static Property Time = new Property(8, long.class, "time", false, "TIME");
        public final static Property LoginUserId = new Property(9, int.class, "loginUserId", false, "LOGIN_USER_ID");
    }

    private final InterConverter typesConverter = new InterConverter();
    private final StringConverter imgsConverter = new StringConverter();

    public OfflineProblemBeanDao(DaoConfig config) {
        super(config);
    }
    
    public OfflineProblemBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"OFFLINE_PROBLEM_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"PROJECT_NAME\" TEXT," + // 1: projectName
                "\"KKS\" TEXT," + // 2: kks
                "\"TASK_CODE\" TEXT," + // 3: taskCode
                "\"TASK_ID\" TEXT," + // 4: taskId
                "\"PROBLEM_INFO\" TEXT," + // 5: problemInfo
                "\"TYPES\" TEXT," + // 6: types
                "\"IMGS\" TEXT," + // 7: imgs
                "\"TIME\" INTEGER NOT NULL ," + // 8: time
                "\"LOGIN_USER_ID\" INTEGER NOT NULL );"); // 9: loginUserId
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"OFFLINE_PROBLEM_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, OfflineProblemBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String projectName = entity.getProjectName();
        if (projectName != null) {
            stmt.bindString(2, projectName);
        }
 
        String kks = entity.getKks();
        if (kks != null) {
            stmt.bindString(3, kks);
        }
 
        String taskCode = entity.getTaskCode();
        if (taskCode != null) {
            stmt.bindString(4, taskCode);
        }
 
        String taskId = entity.getTaskId();
        if (taskId != null) {
            stmt.bindString(5, taskId);
        }
 
        String problemInfo = entity.getProblemInfo();
        if (problemInfo != null) {
            stmt.bindString(6, problemInfo);
        }
 
        List types = entity.getTypes();
        if (types != null) {
            stmt.bindString(7, typesConverter.convertToDatabaseValue(types));
        }
 
        List imgs = entity.getImgs();
        if (imgs != null) {
            stmt.bindString(8, imgsConverter.convertToDatabaseValue(imgs));
        }
        stmt.bindLong(9, entity.getTime());
        stmt.bindLong(10, entity.getLoginUserId());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, OfflineProblemBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String projectName = entity.getProjectName();
        if (projectName != null) {
            stmt.bindString(2, projectName);
        }
 
        String kks = entity.getKks();
        if (kks != null) {
            stmt.bindString(3, kks);
        }
 
        String taskCode = entity.getTaskCode();
        if (taskCode != null) {
            stmt.bindString(4, taskCode);
        }
 
        String taskId = entity.getTaskId();
        if (taskId != null) {
            stmt.bindString(5, taskId);
        }
 
        String problemInfo = entity.getProblemInfo();
        if (problemInfo != null) {
            stmt.bindString(6, problemInfo);
        }
 
        List types = entity.getTypes();
        if (types != null) {
            stmt.bindString(7, typesConverter.convertToDatabaseValue(types));
        }
 
        List imgs = entity.getImgs();
        if (imgs != null) {
            stmt.bindString(8, imgsConverter.convertToDatabaseValue(imgs));
        }
        stmt.bindLong(9, entity.getTime());
        stmt.bindLong(10, entity.getLoginUserId());
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public OfflineProblemBean readEntity(Cursor cursor, int offset) {
        OfflineProblemBean entity = new OfflineProblemBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // projectName
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // kks
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // taskCode
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskId
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // problemInfo
            cursor.isNull(offset + 6) ? null : typesConverter.convertToEntityProperty(cursor.getString(offset + 6)), // types
            cursor.isNull(offset + 7) ? null : imgsConverter.convertToEntityProperty(cursor.getString(offset + 7)), // imgs
            cursor.getLong(offset + 8), // time
            cursor.getInt(offset + 9) // loginUserId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, OfflineProblemBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setProjectName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setKks(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setTaskCode(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setTaskId(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setProblemInfo(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setTypes(cursor.isNull(offset + 6) ? null : typesConverter.convertToEntityProperty(cursor.getString(offset + 6)));
        entity.setImgs(cursor.isNull(offset + 7) ? null : imgsConverter.convertToEntityProperty(cursor.getString(offset + 7)));
        entity.setTime(cursor.getLong(offset + 8));
        entity.setLoginUserId(cursor.getInt(offset + 9));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(OfflineProblemBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(OfflineProblemBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(OfflineProblemBean entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
